<template>
<div>
  <h1>新闻表</h1>
  <table border="1" cellspacing="0" align="center">
    <tr>
      <td>id</td>
      <td>标题</td>
      <td>内容</td>
      <td>浏览次数</td>
      <td>操作</td>
    </tr>
    <tr v-for="i in data">
      <td>{{i.id}}</td>
      <td>{{i.title}}</td>
      <td>{{i.content}}</td>
      <td>{{i.count}}</td>
      <td><button @click="btn2(i.id)">详情</button></td>
    </tr>
  </table>
</div>
</template>

<script>
export default {
  name: "news",
  data(){
    return{
      data:"",
      name:localStorage.getItem("name"),
      password:localStorage.getItem("name")
    }
  },
  methods:{
    btn(){
      this.axios.get("news_s/").then(
        res=>{
          this.data=res.data
        }
      )
    },
    btn2(id){
      this.$router.push({path:"new_xq/",query:{id:id}})
    }
  },
  mounted() {
    this.btn()
  }
}
</script>

<style scoped>

</style>
